﻿using Harvest.Api.Interfaces;

namespace Harvest.Api
{

    public class Repository
    {

        private readonly IRestRequestProvider _provider;


        public ClientsRepository Clients { get; private set; }
        public ContactsRepository Contacts { get; private set; }
        public TasksRepository Tasks { get; private set; }
        public UsersRepository Users { get; private set; }
        public ProjectsRepository Projects { get; private set; }
        public ExpenseCategoriesRepository ExpenseCategories { get; private set; }
        public ExpensesRepository Expenses { get; private set; }
        public TimeTrackingsRepository TimeTrackings { get; private set; }

        public Repository(IRestRequestProvider provider)
        {
            _provider = provider;
            CreateInstanzes();
        }


        private void CreateInstanzes()
        {
            if (Clients == null) Clients = new ClientsRepository(_provider);
            if (Contacts == null) Contacts = new ContactsRepository(_provider);
            if (Tasks == null) Tasks = new TasksRepository(_provider);
            if (Users == null) Users = new UsersRepository(_provider);
            if (Projects == null) Projects = new ProjectsRepository(_provider);
            if (ExpenseCategories == null) ExpenseCategories = new ExpenseCategoriesRepository(_provider);
            if (Expenses == null) Expenses = new ExpensesRepository(_provider);
            if (TimeTrackings == null) TimeTrackings = new TimeTrackingsRepository(_provider);
        }

    }

}
